My $w(\theta)$ emulator has been having lots of problems. I'm going to first test the actual mock calculations to see if I can find the problem.
In [39]:
from pearce.mocks import cat_dict
import numpy as np
from os import path
In [40]:
import matplotlib
#matplotlib.use('Agg')
from matplotlib import pyplot as plt
%matplotlib inline
import seaborn as sns
sns.set()
In [41]:
a = 1.0#0.81120
z = 1.0/a - 1.0
In [42]:
print z
In [43]:
cosmo_params = {'simname':'chinchilla', 'Lbox':400.0, 'scale_factors':[a]}
cat = cat_dict[cosmo_params['simname']](**cosmo_params)#construct the specified catalog!
cat.load_catalog(a)
#halo_masses = cat.halocat.halo_table['halo_mvir']
In [44]:
cat.load_model(a, 'redMagic')
In [45]:
params = cat.model.param_dict.copy()
params['mean_occupation_centrals_assembias_param1'] = 0.0
params['mean_occupation_satellites_assembias_param1'] = 0.0
params['logMmin'] = 12.089
params['sigma_logM'] = 0.33
params['f_c'] = 1.0
params['alpha'] = 1.1
params['logM1'] = 13.3
params['logM0'] = params['logMmin']
print params
In [46]:
cat.populate(params)
In [47]:
theta_bins = np.logspace(np.log10(0.004), 0, 24)#/60
tpoints = (theta_bins[1:]+theta_bins[:-1])/2
In [48]:
wt = cat.calc_wt(theta_bins, do_jackknife=False)
In [49]:
plt.plot(tpoints,wt)
plt.plot(tpoints, 0.04*np.power(tpoints, -0.9))
#plt.yscale('log')
plt.loglog()
plt.xlim([5e-3, 1.1])
#plt.ylim([1e-4, 2.0])
Out[49]:
In [50]:
tpoints
Out[50]:
In [51]:
plt.plot(tpoints,wt/(0.02*np.power(tpoints,-0.8)))
plt.xscale('log')
#plt.loglog()
plt.xlim([1e-2, 1.0])
#plt.ylim([1e-4, 2.0])
Out[51]:
In [52]:
zbin = 1
redmagic_wt = np.loadtxt('/u/ki/swmclau2/Git/pearce/bin/mcmc/buzzard2_wt_%d%d.npy'%(zbin, zbin))
redmagic_nd = np.loadtxt('/u/ki/swmclau2/Git/pearce/bin/mcmc/buzzard2_nd_%d%d.npy'%(zbin, zbin))
In [53]:
print cat.calc_analytic_nd()
In [54]:
redmagic_wt.shape, tpoints.shape
Out[54]:
In [ ]:
In [55]:
from halotools.mock_observables import * # i'm importing so much this is just easier
pos = np.vstack([cat.model.mock.galaxy_table[c] for c in ['x', 'y', 'z']]).T
vels = np.vstack([cat.model.mock.galaxy_table[c] for c in ['vx', 'vy', 'vz']]).T
# TODO is the model cosmo same as the one attached to the cat?
ra, dec, z = mock_survey.ra_dec_z(pos * cat.h, vels, cosmo=cat.cosmology)
ang_pos = np.vstack((np.degrees(ra), np.degrees(dec))).T
ra = np.degrees(ra)
dec = np.degrees(dec)
In [56]:
plt.plot(ra,dec,'.',color='red')
plt.xlim([-180,180])
plt.ylim([-90,90])
plt.ylabel(r'$\delta$ $[{\rm degrees}]$', fontsize=20)
plt.xlabel(r'$\alpha$ $[{\rm degrees}]$', fontsize=20)
plt.xticks(size=15)
plt.yticks(size=15)
plt.title('Mock catalog in angular coordinates', fontsize=20)
Out[56]:
In [57]:
n_rands = 5
rand_pos = np.random.random((pos.shape[0] * n_rands, 3)) * cat.Lbox#*cat.h
rand_vels = np.zeros((pos.shape[0] * n_rands, 3))
rand_ra, rand_dec, rand_z = mock_survey.ra_dec_z(rand_pos * cat.h, rand_vels, cosmo=cat.cosmology)
rand_ang_pos = np.vstack((np.degrees(rand_ra), np.degrees(rand_dec))).T
In [58]:
wt_all = angular_tpcf(ang_pos, theta_bins,randoms = rand_ang_pos, num_threads=1)
In [59]:
print wt_all
print wt
In [60]:
wt_all
Out[60]:
In [61]:
theta_bins
Out[61]:
In [62]:
pos
Out[62]:
In [63]:
cat.cosmology
Out[63]:
In [64]:
pos = np.vstack([cat.model.mock.galaxy_table[c] for c in ['x', 'y', 'z']]).T
coords = pos- cat.model.mock.Lbox/2.0
ra_init, dec_init, z = mock_survey.ra_dec_z(coords*cat.h, vels, cosmo=cat.cosmology)
#keep a complete spherical volume
r = np.sqrt(coords[:,0]**2 + coords[:,1]**2 + coords[:,2]**2)
keep = r<cat.Lbox/2.0
ra = np.degrees(ra_init[keep])
dec = np.degrees(dec_init[keep])
angular_coords = np.vstack((ra,dec)).T
In [65]:
w_theta = angular_tpcf(angular_coords, theta_bins, num_threads='max')
In [66]:
theta_bins
Out[66]:
In [67]:
w_theta
Out[67]:
In [68]:
plt.plot(ra,dec,'.',color='blue', ms = 2.0)
plt.xlim([-180,180])
plt.ylim([-90,90])
plt.ylabel(r'$\delta$ $[{\rm degrees}]$', fontsize=20)
plt.xlabel(r'$\alpha$ $[{\rm degrees}]$', fontsize=20)
plt.xticks(size=15)
plt.yticks(size=15)
plt.title('Mock catalog in angular coordinates', fontsize=20)
Out[68]:
In [74]:
plt.plot(tpoints,wt_all, label = 'Observer in corner')
plt.plot(tpoints, w_theta, label = 'Observer in center')
#plt.xscale('log')
plt.loglog()
plt.xlim([1e-2, 1.0])
#plt.ylim([1e-4, 2.0])
plt.legend(loc='best', fontsize = 15)
plt.xlabel(r'$\theta$ [Degrees]')
plt.ylabel(r'$w(\theta)$')
plt.title('z = %.2f'%(1.0/a - 1.0))
Out[74]:
In [70]:
ra_init, dec_init, z = mock_survey.ra_dec_z(coords*cat.h, vels, cosmo=cat.cosmology)
ra, dec, z = mock_survey.ra_dec_z(pos * cat.h, vels, cosmo=cat.cosmology)